package com.applink.sell_proof.broadcast_receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.applink.sell_proof.DealNotificationDialog;
import com.applink.sell_proof.constant.NotificationKey;

public class PopupReceiver extends BroadcastReceiver {

	private static final String TAG = "PopupReceiver";

	public static PopupReceiver instance() {
		return new PopupReceiver();
	}

	@Override
	public void onReceive(Context context, Intent intent) {
		Log.e(TAG, "Received message and show pop up");
		String type = intent.getStringExtra(NotificationKey.TYPE);
		if (type.equals(TypeNotification.DEAL_CHANGE_STAGE)) {
			abortBroadcast();
			Intent intentForward = new Intent(context,
					DealNotificationDialog.class);
			intentForward.putExtras(intent.getExtras());
			context.startActivity(intentForward);
		}

	}

}
